#!/usr/bin/env ruby1.9
# encoding: UTF-8

require './lib/hindo.rb'

describe Word, "word" do
    it "joins kanji and kana to make a key" do
        Word.make_key("one", "two").should == "one:two"
    end

    it "has a key value" do
        Word.new("a", "b", "c").key.should == "a:b"
    end
end

describe JapaneseTagger, "words" do
    it "returns words" do
        tagger = JapaneseTagger.new
        word = tagger.words("sdcsd")[0]
        word.kanji.should == "sdcsd"
        word.kana.should == "*"
    end

    it "returns kanji and kana" do
        tagger = JapaneseTagger.new
        words = tagger.words("頻度は凄いです")
        words[0].kanji.should == "頻度"
        words[0].kana.should == "ヒンド"
        words[1].kanji.should == "は"
        words[1].kana.should == "ワ"
        words[2].kanji.should == "凄い"
        words[2].kana.should == "スゴイ"
        words[3].kanji.should == "です"
        words[3].kana.should == "デス"
    end

    it "joins verb and auxilary verbs" do
        tagger = JapaneseTagger.new
        words = tagger.words("降ったら")
        words[0].kanji.should == "降ったら"
        words[0].kana.should == "フッタラ"
    end

    it "joins verb and particles" do
        tagger = JapaneseTagger.new
        words = tagger.words("見て来て書いて書いた")
        words[0].kanji.should == "見て"
        words[1].kanji.should == "来て"
        words[2].kanji.should == "書いて"
        words[3].kanji.should == "書いた"
    end

    it "handles auxilary verb at the start of a line" do
        tagger = JapaneseTagger.new
        words = tagger.words("たら")
        words[0].kanji.should == "たら"
        words[0].kana.should == "タラ"
    end
end
